package com.zhanglu.fun.tookit.ddd.domain;

import com.zhanglu.fun.tookit.ddd.entity.UserInfoEntity;
import com.zhanglu.fun.tookit.ddd.repository.UserRepository;
import com.zhanglu.fun.tookit.json.JsonTools;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.StringUtils;

/**
 * @author zhanglu
 *         用户业务聚合对象
 */
@Getter
@Setter
public class UserLoginDomain {
    private Long id;// 唯一标示聚合实体，不一定是主键.....
    private String username;
    private String password;// ......

    public void login() {
        if (StringUtils.isBlank(this.username) || StringUtils.isBlank(this.password)) {
            System.out.println("不通过");
            return;// ......
        }
        UserInfoEntity userIfo = new UserRepository().getUserByUsernameAndPassword(username, password);// .......从仓储中拿到业务想要的信息。返回
        System.out.println("登陆业务获取信息:" + JsonTools.showJSONStringFormat(userIfo));
    }
}
